package com.andy.buyu.server.entity;

import java.util.List;

import com.andy.buyu.server.game.GameConf;
import com.google.common.collect.Lists;

public class ConfStag extends BaseEntity{

	private static final long serialVersionUID = 1L;

	public ConfStag() {
	}
	
	public ConfStag(Long id) {
		super(id);
	}
	
	
	private Integer stagId;
	
	private Integer scriptId;
	
	private Integer starAnm;
	
	private String mapRes;
	
	private String titleMain; // 主标题
	
	private String titleSub;
	
	private Integer nextStage;

	public static String table() {
		return "conf_stag";
	}

	public Integer getStagId() {
		return stagId;
	}

	public void setStagId(Integer stagId) {
		this.stagId = stagId;
	}

	public Integer getScriptId() {
		return scriptId;
	}

	public void setScriptId(Integer scriptId) {
		this.scriptId = scriptId;
	}

	public String getMapRes() {
		return mapRes;
	}

	public void setMapRes(String mapRes) {
		this.mapRes = mapRes;
	}
	
	private List<ConfScript> scripts;
	private boolean haveBoss;
	public List<ConfScript> scripts(){
		if(scripts == null){
			scripts = Lists.newArrayList();
			Integer nextId = scriptId;
			while (nextId != null && nextId > 0) {
				ConfScript script = GameConf.getScript(nextId);
				if(script != null){
					scripts.add(script);
					nextId = script.getNextId();
					if(!haveBoss){
						ConfFish fish = GameConf.getFish(script.getFishId());
						if(fish != null && fish.getType() == 31){
							haveBoss = true;
						}
					}
				}else{
					nextId = null;
				}
			}
		}
//		scripts.sort((s1,s2)->{
//			return s2.getOutTime() - s1.getOutTime();
//		});
		return scripts;
	}

	public String getTitleMain() {
		return titleMain;
	}

	public void setTitleMain(String titleMain) {
		this.titleMain = titleMain;
	}

	public String getTitleSub() {
		return titleSub;
	}

	public void setTitleSub(String titleSub) {
		this.titleSub = titleSub;
	}

	public Integer getStarAnm() {
		return starAnm;
	}

	public void setStarAnm(Integer starAnm) {
		this.starAnm = starAnm;
	}

	public Integer getNextStage() {
		return nextStage;
	}

	public void setNextStage(Integer nextStage) {
		this.nextStage = nextStage;
	}

	public boolean isHaveBoss() {
		return haveBoss;
	}

}
